//
//  ZBBButton.m
//  沙哈拉FM
//
//  Created by dllo on 15/11/2.
//  Copyright © 2015年 S1mpl3. All rights reserved.
//

#import "ZBBButton.h"
#import "FitHeader.h"
@implementation ZBBButton

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addObserver:self forKeyPath:@"isPlay" options:NSKeyValueObservingOptionNew context:nil];
        _rect = frame;
        [self setFontSize:10];
        self.titleLabel.textAlignment = 1;
      
        
    }
    
    
    return self;
}
//label的大小
-(CGRect)titleRectForContentRect:(CGRect)contentRect
{
    
    return CGRectMake(18 * FITWidth, 30 * FITHeight, 40 * FITWidth, 20 * FITHeight);
}
//imageView的大小
-(CGRect)imageRectForContentRect:(CGRect)contentRect
{
    if (_flag) {
        return CGRectMake(16 * FITWidth, 12 * FITHeight, 32 * FITHeight, 32 * FITHeight);
        
    }
    else
    {
        
        return CGRectMake(20 * FITWidth, 2, 34 * FITWidth, 34 * FITHeight);
        
    }
}


-(void)setImage:(UIImage *)image forState:(UIControlState)state
{
    
    [super setImage:image forState:state];
    
    
}

-(void)setTitle:(NSString *)title forState:(UIControlState)state
{
    [super  setTitle:title forState:state];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageEdgeInsets = UIEdgeInsetsMake(10 * FITWidth, 10 * FITHeight, 10 * FITWidth, 10 * FITHeight);
    
    self.titleEdgeInsets = UIEdgeInsetsMake(20 * FITWidth, 0, 0, 0);
    self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
